package com.sinog.basic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sinog.basic.mapper.ResTypeMapper;
import com.sinog.basic.service.ResTypeService;
import com.sinog.core.domain.ResType;
import com.sinog.core.utilbean.Result;
import com.sinog.core.utilbean.ReturnCode;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @desc 资源类型service
 * @author zy
 * @date -
 */
@Service
public class ResTypeServiceImpl extends ServiceImpl<ResTypeMapper,ResType> implements ResTypeService {

    /**
     * 返回所有资源类型
     * [{"id":1300,"text":"树形框"},{"id":800,"text":"输入框"},{"id":100,"text":"菜单"}]
     * @return Result
     */
    @Override
    public Result selectResourceType() {
        ResType bean = new ResType();
        List<ResType> list = bean.selectList(new QueryWrapper<ResType>().select("id","name as text"));
        if(list.isEmpty()) {
            Result.failure(ReturnCode.SELECT_FAILED);
        }
        return Result.success(list);
    }
}